<template>
  <div class="home">
    <!-- <h1>主页</h1> -->
    <div class="home_header">
      <div class="ipt">
        <input type="text" placeholder="sport 运动" />
        <div class="search">
          <img src="../assets/images/search.png" />
        </div>
      </div>
      <div class="logo">
        <img src="../assets/images//sport.png" alt="LOGO" />
      </div>
    </div>

    <div class="home_conten">
      <div class="home_text">直播</div>
      <div class="home_text active">推荐</div>
      <div class="home_text">会员</div>
    </div>

    <div class="home_nav">
      <div class="home_nav_content">
        <div class="home_nav_top">
          <img src="../assets/images/headerimg.jpg" />
        </div>
        <div class="home_nav_bottom">全部课程</div>
      </div>
      <div class="home_nav_content">
        <div class="home_nav_top">
          <img src="../assets/images/headerimg.jpg" />
        </div>
        <div class="home_nav_bottom">全部课程</div>
      </div>
      <div class="home_nav_content">
        <div class="home_nav_top">
          <img src="../assets/images/headerimg.jpg" />
        </div>
        <div class="home_nav_bottom">全部课程</div>
      </div>
      <div class="home_nav_content">
        <div class="home_nav_top">
          <img src="../assets/images/headerimg.jpg" />
        </div>
        <div class="home_nav_bottom">全部课程</div>
      </div>
      <div class="home_nav_content">
        <div class="home_nav_top">
          <img src="../assets/images/headerimg.jpg" />
        </div>
        <div class="home_nav_bottom">全部课程</div>
      </div>
    </div>

    <div class="home_main">
      <div class="home_main_content">
        <div class="img">
          <img src="../assets/images/headerimg.jpg" />
          <div class="score">9 分</div>
          <div class="time">10 分钟</div>
        </div>
        <div class="title">sport 运动: 自律拥抱生活</div>
        <div class="info">
          <div class="info_left">
            <img
              style="border-radius: 50%"
              src="../assets//images/headerimg.jpg"
              alt=""
            />
          </div>
          <div class="info_middle">人鱼线</div>
          <div class="info_right">+</div>
        </div>
      </div>
      <div class="home_main_content">
        <div class="img">
          <img src="../assets/images/headerimg.jpg" />
          <div class="score">9 分</div>
          <div class="time">10 分钟</div>
        </div>
        <div class="title">sport 运动: 自律拥抱生活</div>
        <div class="info">
          <div class="info_left">
            <img
              style="border-radius: 50%"
              src="../assets//images/headerimg.jpg"
              alt=""
            />
          </div>
          <div class="info_middle">人鱼线</div>
          <div class="info_right">+</div>
        </div>
      </div>
    </div>

    <!-- 底部tabBar组件 -->
    <TabBarView />

    <!-- 加载页面组件 -->
    <LoadingView v-if="isLoading" class="myView" />
  </div>
</template>

<style lang="scss" scoped>
img {
  vertical-align: bottom;
  width: 30px;
}

.home {
  position: relative;

  .home_header {
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    padding: 10px;
    width: 100vw;
    height: 50px;

    .ipt {
      position: relative;

      input {
        width: 300px;
        height: 35px;
        border-radius: 20px;
        padding: 0 0 0 30px;
        outline: none;
        border: 1px solid #051338;

        &:focus {
          border: 2px solid #051338;
        }
      }

      .search {
        position: absolute;
        top: 50%;
        left: 10px;
        margin-top: -10px;

        img {
          width: 20px;
        }
      }
    }

    .logo {
      img {
        width: 30px;
      }
    }
  }

  .home_conten {
    width: 100vw;
    height: 60px;
    // background: aqua;
    display: flex;
    align-items: center;
    justify-content: start;
    padding: 0 15px;

    .home_text {
      height: 100%;
      font-weight: 700;
      font-size: 36px;
      margin: 0 30px 0 0;
      // border-bottom: 5px solid aqua;

      &.active {
        border-bottom: 5px solid aqua;
      }
    }
  }

  .home_nav {
    width: 350px;
    height: 120px;
    margin: 0 auto;
    // background: red;
    display: flex;
    justify-content: start;
    align-items: center;
    // padding: 0 15px;
    overflow-x: auto; /* 允许水平滚动 */
    overflow-y: hidden; /* 隐藏垂直滚动 */
    white-space: nowrap; /* 让子元素水平排列 */

    &::-webkit-scrollbar {
      display: none;
    }

    .home_nav_content {
      margin: 0 20px 0 0;
      width: 90%;
      // background: aqua;

      .home_nav_top {
        img {
          width: 70px;
          border-radius: 50%;
        }
      }

      .home_nav_bottom {
        margin: 10px 0 0 0;
      }
    }
  }

  .home_main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    box-sizing: border-box;

    .home_main_content {
      .img {
        position: relative;

        img {
          width: 160px;
          box-sizing: border-box;
        }

        .score {
          position: absolute;
          left: 0;
          bottom: 10px;
          background: rgba(128, 128, 128, 0.5);
          border-radius: 5px;
          color: white;
          padding: 2px 10px;
        }

        .time {
          position: absolute;
          right: 0;
          bottom: 10px;
          background: rgba(128, 128, 128, 0.5);
          border-radius: 5px;
          color: white;
          padding: 2px 10px;
        }
      }

      .title {
        width: 160px;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        word-wrap: break-word;
        text-overflow: ellipsis;
      }
    }
  }

  .info {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .myView {
    position: fixed;
    top: 0;
    left: 0;
  }
}
</style>

<!-- <script>
import { Options, Vue } from "vue-class-component";
import TabBarView from "@/components/TabbarView.vue";
import LoadingView from "@/views/LoadingView.vue";

@Options({
  components: {
    TabBarView,
    LoadingView,
  },
})
export default class HomeView extends Vue {
  name = "HomeView";
}
</script> -->

<script>
import { defineComponent, ref } from "vue";
import TabBarView from "@/components/TabbarView.vue";
import LoadingView from "@/views/LoadingView.vue";

export default defineComponent({
  name: "HomeView",
  components: {
    TabBarView,
    LoadingView,
  },
  setup() {
    const isLoading = ref(true);

    setTimeout(() => {
      isLoading.value = false;
    }, 3000);

    return { isLoading };
  },
});
</script>
